﻿using Entity.Models;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Entity.Mapping
{
    public class DepositoMap : EntityTypeConfiguration<Deposito>
    {
        public DepositoMap()
        {
            // Chave Primaria
            this.HasKey(t => t.Id);

            //Propriedades
            this.Property(t => t.Id)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity);

            // Mapeamento Tabela Coluna
            this.ToTable("Deposito", "Sgf");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.BancoId).HasColumnName("BancoId");
            this.Property(t => t.Valor).HasColumnName("Valor");
            this.Property(t => t.DataDeposito).HasColumnName("DataDeposito");
            this.Property(t => t.UsuarioId).HasColumnName("UsuarioId");

            // Relacionamento
            this.HasRequired(t => t.Banco)
                .WithMany(t => t.Deposito)
                .HasForeignKey(d => d.BancoId);

            this.HasRequired(t => t.Usuario)
                .WithMany(t => t.Deposito)
                .HasForeignKey(d => d.UsuarioId);
        }
    }
}
